<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>退款跟踪</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/dist/plugins/webuploader-0.1.5/webuploader.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=f5a12a1d">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style type="text/css">
        .user {
            height: 30px;
            line-height: 30px;
            max-height: 30px;
            float: left;
            text-align: left;
            min-width: 32px;
            padding-left: 1px;
            overflow: hidden;
            cursor: pointer;
        }

        .lineOne {
            text-align: left;
        }

        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            /*display: -webkit-box;*/
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            max-height: 34px;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .user:hover {
            background-color: #cfd4d1;
        }

        .userbox .select.user {
            color: #fff;
            background-color: #045B9E;
        }

        .span-btn {
            position: absolute;
            left: 10px;
            margin-top: 4px;
            cursor: pointer;
        }

        .auditorName {
            text-align: center;
        }

        .IcoNormal {
            float: left;
            border-bottom: 0px;
            border-left: 0px;
            background-color: transparent;
            width: 16px;
            height: 16px;
            vertical-align: middle;
            border-top: 0px;
            border-right: 0px;
            background-image: url(/dist/img/upload_normal.gif);
            background-repeat: no-repeat;
            float: left;
        }

        .progressobj {
            height: 20px;
        }

        .pull-left {
            float: left;
            padding-left: 6px;
        }

        .progressobj .delfile {
            float: left;
            margin-left: 10px;
        }

        .select {
            color: #fff;
            background-color: #045B9E;
        }

        .table-detail td.td-value2 {
            padding: 1px !important;
            text-align: left !important;
        }

        .td-value2 input {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
        }

        .td-value2 select {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
            color: #2a8cec;
        }

        td .sp-value {
            display: inline-block;
            padding-left: 6px;
            word-wrap: break-word;
        }

        td {
            color: #2a8cec;
        }

        td.td-title, td select, td .filename, td.td-module {
            color: black;
        }

        .table-detail-payee:nth-child(even) td.td-title {
            background-color: white;
        }

        .printDiv {
            display: none;
        }

        .printInput {
            width: 200px;
        }

        .printBtn {
            margin: 0 auto;
            display: block;
        }

        .webuploader-pick {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            display: block;
            padding: 0 4px;
            height: 22px;
            line-height: 22px;
            padding-left: 15px;
            margin: 0 auto;
            width: 70px;
            margin-top: 6px;
            border-radius: 4px;
        }

        .webuploader-pick-hover {
            color: #fff !important;
            background: url(/dist/img/fjT2.png) no-repeat 5px center;
            background-color: #0F6099;

        }

        #divUploadedFiles {
            /*padding: 4px;*/
            padding-bottom: 0;
        }


    </style>
</head>
<body>
<iframe id="ifAttach" style="display:none"></iframe>
<div class="layout" style="left:0px;top:0px;right:0px;bottom:0px;" id="app">

    <div class="div-td-content-more"><i></i></div>
    <div class="center" style="overflow:auto;overflow-x:hidden;padding-left:8px;padding-right:8px;height: 400px">
        <table class="table-detail">
            <tr class="no-print">
                <td colspan="6" class=" no-print td-module" style="background: yellow;">基本信息</td>
            </tr>
            <tr>
                <td style="width:16%;" class="td-title">款项用途</td>
                <td style="width:17%;">
                    <span class="pull-left">{{money.main.type}}</span>
                </td>
                <td style="width:16%;" class="td-title">用款流水单号</td>
                <td style="width:17%;" colspan="3"><span class="pull-left">{{money.main.seriesNumber}}</span>
                </td>
            </tr>
            <tr>
                <td style="width:16%;" class="td-title">预计退款日期</td>
                <td style="width:17%;" class="td-value2">
                    <input v-if="pageType=='edit'" type="text"
                           v-model="money.main.estimatedReturnDate"
                           @focus="showDatePicker2($event,'estimatedReturnDate')"/>
                    <span v-else class="pull-left">{{money.main.estimatedReturnDate}}</span>
                </td>
                <td style="width:16%;" class="td-title">预计退款金额</td>
                <td style="width:17%;" class="td-value2">
                    <!-- <input v-if="pageType=='edit'&&!showactualReturn()" type="text"
                                                                 @blur="strFormat($event.target,'money.main.estimatedReturnMoney')"
                                                                 @focus="strFormatF($event.target,'money.main.estimatedReturnMoney')"
                                                                 v-onedate="fmoney(money.main.estimatedReturnMoney)"/>-->
                    <span class="pull-left">{{fmoney(money.main.estimatedReturnMoney)}}</span>
                    <span style="color: #2a8cec;position:absolute;left:105px;top: 1px;">元</span>
                </td>
                <td style="width:16%;" class="td-title">跟踪人</td>
                <td style="width:17%;" class="td-value2">
                    <!--<input v-if="pageType=='edit'&&!showactualReturn()" type="text"
                                                                class="returnPayee"
                                                                v-model="money.main.returnPayeeName"/>-->
                    <span class="pull-left">{{money.main.returnPayeeName}}</span>
                </td>
            </tr>
            <tr>
                <td style="width:16%;" class="td-title">实际退款日期</td>
                <td style="width:17%;" class="td-value2"><input v-if="pageType=='edit'" type="text"
                                                                v-model="money.main.actualReturnDate"
                                                                @focus="showDatePicker2($event,'actualReturnDate')"/>
                    <span v-else class="pull-left">{{money.main.actualReturnDate}}</span></td>
                <td style="width:16%;" class="td-title">实际退款金额</td>
                <td style="width:17%;" class="td-value2"><input v-if="pageType=='edit'" type="text"
                                                                @blur="strFormat($event.target,'money.main.actualReturnMoney')"
                                                                @focus="strFormatF($event.target,'money.main.actualReturnMoney')"
                                                                v-onedate="fmoney(money.main.actualReturnMoney)"/>
                    <span v-else class="pull-left">{{fmoney(money.main.actualReturnMoney)}}</span>
                    <span style="color: #2a8cec;position:absolute;left:105px;top: 1px;">元</span>
                </td>
                <td style="width:16%;" class="td-title">是否结清</td>
                <td class="td-value2">
                    <select v-model="money.main.haveReturnClear" v-if="pageType=='edit'">
                        <option>
                        </option>
                        <option value="1">是
                        </option>
                        <option value="0">否
                        </option>
                    </select>
                    <span v-else class="pull-left">{{money.main.haveReturnClear=='1'?'是':'否'}}</span>
                </td>
            </tr>
            <tr>
                <td class="td-title">备注</td>
                <td colspan="5" style="text-align: left;">
                    <textarea type="text" v-if="pageType=='edit'" v-model="money.main.returnRemark"></textarea>
                    <span class="sp-value" v-else>{{money.main.returnRemark}}</span>
                </td>
            </tr>

        </table>
        <!--审批进度-->
        <table class="table-detail no-print" style="border-top-width:0px;">
            <tr>
                <td class=" td-module" colspan="6" style="background: yellow;">审批进度</td>
            </tr>
            <tr>
                <td class="td-title" style="width:16%;">审核顺序</td>
                <td class="td-title" style="width:17%;">审核人员</td>
                <td class="td-title" style="width:16%;">审核状态</td>
                <td class="td-title" style="width:17%;">审核时间</td>
                <td class="td-title" colspan="2">审核意见</td>
            </tr>
            <tr v-for="(item,i) in money.auditList">
                <td>
                    <!--<span v-if="pageType=='edit'" class="span-btn">
                        <span style="font-size:20px;"
                              @click="addItem('auditors','Audit')"> + </span>
                        <span style="font-size:20px;"
                              @click="delItem('auditors',i,'审核人')"> - </span>
                    </span>-->
                    <span>第{{i+1}}审核人</span>
                </td>
                <td>
                    <input v-if="pageType=='edit'" class="auditorName" type="text"
                           :value="item.auditorName" :idx="i"/>
                    <span v-else>{{item.auditorName}}</span>
                </td>
                <td>
                    <span v-if="item.auditFlag==0" style="color:red;">{{convertAuditFlagToName(item.auditFlag)}}</span>
                    <span v-else>{{convertAuditFlagToName(item.auditFlag)}}</span>
                </td>
                <td>{{item.auditTime}}</td>
                <td colspan="2"><input type="text" v-model="item.auditAdvise"/></td>
            </tr>
            <template v-if="historys.length!=0">
                <tr class="no-print">
                    <td colspan="6" class=" td-module" style="background: yellow;">历史驳回记录</td>
                </tr>
                <tr class="no-print" v-for="(item,i) in historys">
                    <td class="td-title">驳回人员</td>
                    <td>{{item.auditorName}}</td>
                    <td class="td-title">驳回时间</td>
                    <td>{{item.auditTime}}</td>
                    <td class="td-title">驳回原因</td>
                    <td class="lineOne"><span class="pull-left">{{item.auditAdvise}}</span></td>
                </tr>
            </template>
        </table>
        <div class="south no-print" style="height:50px;line-height:50px;text-align:center;" v-if="pageType!='browser'">
            <!-- <input type="button" style="margin-left:20px;" v-if="pageType=='edit'"
                    value="保存草稿" class="btn btn-primary btn-sm" @click="save(-1)"/>-->
            <input type="button" style="margin-left:20px;" v-if="pageType=='edit'"
                   value="提交申请" class="btn btn-primary btn-sm" @click="save(0)">
            <!-- -1 跟踪人第一审核草稿（上级） 0审核中 1通过 2驳回
            3 跟踪人第二审核草稿（上级，财务）4审核中 5通过 6驳回-->
            <input type="button" style="margin-left:20px;"
                   v-if="pageType=='applyAudit' && money.main.refundFlag=='0'&& money.main.currentAuditorId==currentUser.id"
                   value="通过" class="btn btn-primary btn-sm" @click="applyAudit(1)">
            <input type="button" style="margin-left:20px;"
                   v-if=" pageType=='applyAudit' && money.main.refundFlag=='0' && money.main.currentAuditorId==currentUser.id"
                   value="驳回" class="btn btn-primary btn-sm" @click="applyAudit(2)">
        </div>
    </div>

</div>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=63aed32f"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script src="/dist/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="/dist/js/pages/apply/money/class.js"></script>
<script type="text/javascript" src="/dist/js/pages/system/systemService.js"></script>
<script type="text/javascript" src="/dist/js/pages/common/commonService.js"></script>
<script type="text/javascript" src="/dist/js/pages/common/changeMoneyToChinese.js"></script>
<script type="text/javascript" src="/dist/plugins/print/print.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    var api = frameElement.api, W = api.opener;

    function refresh() {
        location.reload();
    }

    function close() {
        api.close();
    }

    // 注册一个局自定义指令 `v-inputOnce`
    Vue.directive('onedate', {
        // 当被绑定的元素插入到 DOM 中时……
        update: function (el, binding) {
            // 聚焦元素
            if (app.pageType != 'add') {
                if (el.value == "NaN.undefined" || el.value == "") {
                    el.value = binding.value
                }
            }
        },
        componentUpdated: function (el, binding) {
            // 聚焦元素


        }
    })
    var app = new Vue({
        el: "#app",
        data: {
            openType: $.wyui.page.urlParams.openType ? $.wyui.page.urlParams.openType : 'top',
            currentUser: getCurrentUser(),
            pageType: "edit",
            money: {
                main: new Money.Main(),
                auditList: [],
            },
            auditList: [],
            uploader: null,
            copierSelectedIdx: -1,
            price: 0,
            priceChinese: "",
            historys: [],

        },
        methods: {
            /*  showactualReturn: function () {
                  var that = this;
                  if (that.money.main.refundFlag == 1) {
                      return true;
                  } else if (that.money.main.refundFlag < 3) {
                      return false;
                  } else {
                      return true;
                  }
              },*/
            showCopierReturn: function () {
                if (this.money.main.auditFlag != '-1') {
                    var copierIds = new Array();
                    for (var i = 0; i < this.money.copiers.length; i++) {
                        copierIds.push(this.money.copiers[i].copyPersonId);
                    }
                    return $.inArray(currentUser.id, copierIds) > -1;
                }
                return false;
            },
            fjStyle: function (fjName) {
                if (fjName) {
                    var type = fjName.substring(fjName.lastIndexOf('.') + 1);
                    return 'img fj-' + type
                }
                return 'img'
            },
            fmoney: function (s, n) {
                console.log(s);
                if (s && typeof(s) != "undefined") {
                    n = n > 0 && n <= 20 ? n : 2;
                    s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
                    var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1],
                        t = "";
                    for (i = 0; i < l.length; i++) {
                        t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
                    }
                    return t.split("").reverse().join("") + "." + r;
                } else {
                    return '';
                }
            },
            strFormatF: function (target, data) {
                var value = '';
                var dataList = data.split('.');

                if (dataList.length > 0) {
                    if (dataList.length == 1) {
                        value = this[dataList[0]]
                    }
                    if (dataList.length == 2) {
                        value = this[dataList[0]][dataList[1]]
                    }
                    if (dataList.length == 3) {
                        value = this[dataList[0]][dataList[1]][dataList[2]]
                    }
                    if (dataList.length == 4) {
                        value = this[dataList[0]][dataList[1]][dataList[2]][dataList[3]]
                    }
                    if (dataList.length == 5) {
                        value = this[dataList[0]][dataList[1]][dataList[2]][dataList[3]][dataList[4]]
                    }
                }
                if (!value || value == '0.00') {
                    console.log('获取焦点', value)
                    value = '';
                }
                target.value = value;
            },
            strFormat: function (target, data) {
                //此结果为了展示数据
                var value = (target.value).trim();
                value = value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g, '');
                if (!value) {
                    value = 0
                }
                ;
                //此结果为data存入数据
                var dataList = data.split('.');

                if (dataList.length > 0) {
                    if (dataList.length == 1) {
                        this[dataList[0]] = value;
                    }
                    if (dataList.length == 2) {
                        this[dataList[0]][dataList[1]] = value;
                    }
                    if (dataList.length == 3) {
                        this[dataList[0]][dataList[1]][dataList[2]] = value;
                    }
                    if (dataList.length == 4) {
                        this[dataList[0]][dataList[1]][dataList[2]][dataList[3]] = value;
                    }
                    if (dataList.length == 5) {
                        this[dataList[0]][dataList[1]][dataList[2]][dataList[3]][dataList[4]] = value;
                    }
                }
                target.value = this.fmoney(value);
            },
            convertAuditFlagToName: function (auditFlag) {
                //-1 跟踪人第一审核草稿（上级） 0审核中 1通过 2驳回
                //3 跟踪人第二审核草稿（上级，财务）4审核中 5通过 6驳回
                var auditFlag = auditFlag.toString();
                switch (auditFlag) {
                    case "-1":
                        return "未提交";
                        break;
                    case "0":
                        return "审核中";
                        break;
                    case "1":
                        return "通过";
                        break;
                    case "2":
                        return "驳回";
                        break;
                    default :
                        break;
                }
            },
            addItem: function (prop, className) {
                this.money[prop].push(new Money[className]());
                setTimeout(function () {
                    initAutoComplete();
                }, 300);

            },
            delItem: function (prop, i, desc) {
                if (this.money[prop].length <= 1) {
                    alert("请至少保留一位审核人！")
                    return
                }
                this.money[prop].splice(i, 1);
            },
            save: function (auditFlag) {
                //-1 跟踪人第一审核草稿（上级）  1通过 2驳回
                //3 跟踪人第二审核草稿（上级，财务）  6驳回
                var that = this;
                //console.log(that.money.main.refundFlag<3);
                /*if (auditFlag == -1 && that.money.main.refundFlag != 1 && that.money.main.refundFlag < 3) {
                    that.money.main.refundFlag = -1;
                }
                if (auditFlag == -1 && that.money.main.refundFlag == 1) {
                    that.money.main.refundFlag = 3;
                }
                if (auditFlag == 0 && that.money.main.refundFlag != 1 && that.money.main.refundFlag < 3) {
                    that.money.main.refundFlag = 0;
                }
                if (auditFlag == 0 && that.money.main.refundFlag == 1) {
                    that.money.main.refundFlag = 4;
                }
                if (auditFlag == -1 && that.money.main.refundFlag >= 3) {
                    that.money.main.refundFlag = 3;
                }
                if (auditFlag == 0 && that.money.main.refundFlag >= 3) {
                    that.money.main.refundFlag = 4;
                }*/
                that.money.main.refundFlag = auditFlag;
                if (auditFlag == 0) {
                    if (that.money.main.refundFlag == 0) {
                        if (this.money.main.estimatedReturnDate == '') {
                            alert("请填写预计退款日期");
                            return;
                        }
                        if (this.money.main.actualReturnDate == '') {
                            alert("请填写实际退款日期");
                            return;
                        }
                        if (this.money.main.actualReturnMoney == '') {
                            alert("请填写实际退款金额");
                            return;
                        }
                        if (this.money.main.haveReturnClear == '') {
                            alert("请填写是否结清");
                            return;
                        }
                    }
                }
                $.wyui.postMethod(urlConfig.apply.money.saveRefund, trimRN(that.money), function (data) {
                    alert("操作成功");
                    if (that.openType == 'top') {
                        parent.refresh();
//                    var $iframe = top.findIframeByName("用款申请");
//                    $iframe[0].contentWindow.refresh();
                        api.close();
                    } else {
                        api.close();
                        // refresh();
                    }
                });
            }
            ,
            applyAudit: function (auditFlag) {

                if (auditFlag == 1) {

                    if (!confirm("确定要通过吗？")) {
                        return;
                    }
                }
                var that = this;
                var advise = '';
                if (auditFlag == 2 /*&& advise == ''*/) {
                    this.copierReturn(1)
                    //alert('请填写审核意见');
                    return;
                }
                if (advise == "") {
                    advise = "同意！";
                }

                //var refundFlag = '';
                //-1 跟踪人第一审核草稿（上级） 0审核中 1通过 2驳回
                //3 跟踪人第二审核草稿（上级，财务）4审核中 5通过 6驳回
                /*if (auditFlag == 1 && that.money.main.refundFlag == 0) {
                    refundFlag = 1;
                } else if (auditFlag == 1 && that.money.main.refundFlag == 4) {
                    refundFlag = 5;
                } else if (auditFlag == 2 && that.money.main.refundFlag == 0) {
                    refundFlag = 2;
                } else if (auditFlag == 2 && that.money.main.refundFlag == 4) {
                    refundFlag = 6;
                }*/
                $.wyui.postMethod(urlConfig.apply.money.refundAudit, {
                    id: that.money.main.id,
                    userId: getCurrentUser().id,
                    refundFlag: auditFlag,
                    advise: advise
                }, function () {
                    alert("审核成功");
                    if (that.openType == 'top') {
                        /*  if (parent.app) {
                              parent.refresh();
                          }*/
                        if (top.findTabPanelByName("退款跟踪")) {
                            var $iframe = top.findIframeByName("退款跟踪");
                            $iframe[0].contentWindow.refresh();
                        }
                        api.close();
                    } else {

                        api.close();
                    }

                });
            }
            ,
            copierReturn: function (type) {
                //type : 0-抄送人驳回  1-审核人驳回
                $.dialog({
                    content: 'url:genzong_copierReturnReason.html?id=' + this.money.main.id + '&openType=' + this.openType + '&refundFlag=' + this.money.main.refundFlag + "&t=" + new Date(),
                    title: '驳回',
                    width: 300,
                    height: 250,
                    max: false,
                    min: false,
                    lock: true
                });
            }
            ,
            goBack: function () {
                api.close();
            }
            ,
            showDatePicker2: function (e, item) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        if (item == 'estimatedReturnDate') {
                            that.money.main.estimatedReturnDate = dp.cal.getNewDateStr();
                        } else if (item == 'actualReturnDate') {
                            that.money.main.actualReturnDate = dp.cal.getNewDateStr();
                        }
                        return true;
                    }
                });
                $(e.target).blur();
            }
            ,
            inputFocus: function (id) {
                $("#" + id).focus();
            }
            ,
            selectUser: function (i, prop) {
                this.copierSelectedIdx = -1;
                this[prop] = i;
            }
            ,
            unselectUser: function () {
                this.copierSelectedIdx = -1;
            }
            ,
            deleteUser: function (event) {
                if (event.keyCode == 46 || event.keyCode == 8 && event.target.value == "") {
                    if (this.copierSelectedIdx > -1) {
                        this.money.copiers.splice(this.copierSelectedIdx, 1);
                        this.copierSelectedIdx = -1;
                    } else {
                        this.copierSelectedIdx = this.money.copiers.length - 1;
                    }
                }
            }
            ,
        },
        mounted: function () {
            //页面操作状态
            this.pageType = $.wyui.page.urlParams.pageType;
            //上传附件
            var that = this;
            //编辑
            if (parseInt($.wyui.page.urlParams.id) > 0) {
                $.wyui.postMethod(urlConfig.apply.money.getByIdForRefund, {
                    id: $.wyui.page.urlParams.id,
                    userId: getCurrentUser().id
                }, function (data) {
                    that.auditList = data.auditList;
                    that.historys = data.historys;
                    that.money.main = data.main;

                    for (var i = 0; i < that.auditList.length; i++) {
                        var a = {
                            auditorId: that.auditList[i].auditorId,
                            auditFlag: that.auditList[i].auditFlag,
                            auditorName: that.auditList[i].roleName + "-" + that.auditList[i].auditorName,
                            roleName: that.auditList[i].roleName,
                            auditAdvise: that.auditList[i].auditAdvise,
                            auditTime: that.auditList[i].auditTime,
                        };
                        that.money.auditList.push(a);
                    }
                    setTimeout(function () {
                        initAutoComplete();
                    }, 300);
                });
            }
            ;
        }
    });
</script>
<script>
    $(function () {
        initAutoComplete();
    });

    function initAutoComplete() {
        $(".auditorName,.copier,.returnPayee").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                if ($(this).hasClass("auditorName")) {
                    var idx = $(this).attr("idx");
                    app.money.auditList[idx].auditorId = user.id;
                    app.money.auditList[idx].auditorName = user.roleName + "-" + user.name;
                    app.money.auditList[idx].roleName = user.roleName;
                } else if ($(this).hasClass("returnPayee")) {
                    app.money.main.returnPayeeId = user.id;
                    app.money.main.returnPayeeName = user.name;
                    app.money.main.returnPayeeRoleName = user.roleName;
                }
                return false;
            },
            height: 210,
            width: 300
        });
    }

    function printOk() {

    }
</script>
</body>
</html>